package cn.yunsenlin.formula.cloud.group;

import cn.yunsenlin.formula.cloud.interfaces.GroupService;
import cn.yunsenlin.formula.cloud.mysql.bean.generator.TbGroup;
import cn.yunsenlin.formula.cloud.responsibility.ResponseResponsibilityHandler;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;

/**
 * 检测计算组更新信息是否合法
 */
@Service
public class GroupUpdateValidRRH extends ResponseResponsibilityHandler {
    private final GroupService groupService;

    public GroupUpdateValidRRH(GroupService groupService) {
        this.groupService = groupService;
    }

    @Override
    protected Object doHandler(HttpServletResponse response, Object object) {
        return null;
    }

    @Override
    protected boolean continueAble(HttpServletResponse response, Object object) {
        if (!groupService.updateGroupParentIdCheck((TbGroup) object)){
            response.setStatus(400);
            return false;
        }
        return true;
    }
}
